home *** CD-ROM | disk | FTP | other *** search
- /*
- * Copyright (C) 1994, Silicon Graphics, Inc.
- * All Rights Reserved.
- *
- * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
- * the contents of this file may not be disclosed to third parties, copied or
- * duplicated in any form, in whole or in part, without the prior written
- * permission of Silicon Graphics, Inc.
- *
- * RESTRICTED RIGHTS LEGEND:
- * Use, duplication or disclosure by the Government is subject to restrictions
- * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
- * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
- * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
- * rights reserved under the Copyright Laws of the United States.
- */
- /*----------------------------------------------------------------------------
- *
- * file : draw.c
- *
- * Author : Yusuf Attarwala
- * Date : May 93
- *
- *---------------------------------------------------------------------------*/
- #include <math.h>
- #include <stdio.h>
- #include <gl/device.h>
-
- #include "globals_vol.h"
-
- #define ABS(a) (((a) >= 0) ? (a) : -(a))
- #define _XY 1
- #define _YZ 2
- #define _ZX 3
- #define _MXY -1
- #define _MYZ -2
- #define _MZX -3
-
- void drawAxes(),
- drawClippingPlane();
- int isFacing();
- int optimumSet();
- static int lastSet = 0;
- static int visitedDrawscene = 0;
-
- static float t0[] = {0.0,0.0};
- static float t1[] = {1.0,0.0};
- static float t2[] = {1.0,1.0};
- static float t3[] = {0.0,1.0};
-
- static float xyNorm[] = {0.0,0.0,1.0};
- static float mxyNorm[] = {0.0,0.0,-1.0};
- static float zxNorm[] = {0.0,1.0,0.0};
- static float mzxNorm[] = {0.0,-1.0,0.0};
- static float yzNorm[] = {1.0,0.0,0.0};
- static float myzNorm[] = {-1.0,0.0,0.0};
-
- float x_sep = 1.0;
- float y_sep = 1.0;
- float z_sep = 1.0;
-
- void xt3f(){}
-
- void
- drawScene()
- {
- int i,j;
- int viewAxis;
- float tcoord[4][3];
- int skipPolyCounter;
-
- /*printf("drawscene \n");*/
-
- /* the following is so that 2d texture is bound
- first few times, regardless of lastSet = viewAxis */
- visitedDrawscene++;
- if (visitedDrawscene > 100) visitedDrawscene = 10;
-
- GLXwinset(XtDisplay(glw), XtWindow(glw));
-
- if (fog) {
- c3f(fogRGB);
- fogvertex(FG_ON,0);
- }
- else {
- RGBcolor(0,0,0);
- }
- clear();
-
- /* enable arbitrary clipping planes */
- if (doClipping) {
- for (i=0;i<6;i++) {
- if (clip[i].onOff == 1) {
- clipplane(i,CP_DEFINE,clip[i].coeff);
- clipplane(i,CP_ON,0);
- }
- }
- }
-
- viewAxis = optimumSet();
-
- switch(drawMode) {
- case WIREFRAME :
- pushmatrix();
- switch(viewAxis) {
- case _XY :
- case _MXY :
- /*
- translate(0,0,-z_sep*depth/2.0);
- for (i=0;i<depth;i++) {
- translate(0,0,z_sep);
- */
- RGBcolor(255,0,0);
- bgnclosedline();
- v3f(xy_v0);
- v3f(xy_v1);
- v3f(xy_v2);
- v3f(xy_v3);
- endclosedline();
- /*
- }
- */
- break;
- case _YZ :
- case _MYZ :
- /*
- translate(-x_sep*width/2.0,0,0);
- for (i=0;i<width;i++) {
- translate(x_sep,0,0);
- */
- RGBcolor(0,255,0);
- bgnclosedline();
- v3f(yz_v0);
- v3f(yz_v1);
- v3f(yz_v2);
- v3f(yz_v3);
- endclosedline();
- /*
- }
- */
- break;
- case _ZX :
- case _MZX :
- /*
- translate(0,-y_sep*height/2.0,0);
- for (i=0;i<height;i++) {
- translate(0,y_sep,0);
- */
- RGBcolor(0,0,255);
- bgnclosedline();
- v3f(zx_v0);
- v3f(zx_v1);
- v3f(zx_v2);
- v3f(zx_v3);
- endclosedline();
- /*
- }
- */
- break;
- default :
- printf("weird view \n");
- break;
- }
- popmatrix();
- if (drawAxis) drawAxes();
-
- if (doClipping && displayClipPlanes) {
- for (i=0;i<6;i++) {
- if (clip[i].onOff==1) {
- drawClippingPlane(i);
- }
- }
- }
- break;
-
- /* the real thing */
- case TEXTURED :
-
- if (doLighting) {
- lmbind(LMODEL,1); /* bind light model */
- pushmatrix();
- lmbind(LIGHT0,1);
- popmatrix();
- lmbind(MATERIAL,1); /* bind material */
- shademodel(FLAT);
- }
-
- if (!dontBlend)
- blendfunction( BF_SA, BF_MSA );
-
- pushmatrix();
-
- if (textureMode == TEXTURE_2D) { /* TWO DIM */
-
- tevbind(TV_ENV0,1);
- switch(viewAxis) {
- case _XY :
- skipPolyCounter = 0;
- translate(0,0,z_sep*depth/2.0);
- #ifndef OPTI
- if (lastSet != viewAxis || visitedDrawscene < 5) texbind(TX_TEXTURE_0,100);
- #endif
- for (i=0;i<depth;i++) {
- /* if (degenMode && qtest()) break; */
- translate(0,0,-z_sep);
-
- /* weird logic to skip polygons */
- if (lightWeight) {
- if (skipPolyCounter < lightWeightCount) {
- skipPolyCounter++;
- continue;
- }
- else {
- skipPolyCounter = 0;
- }
- }
-
- #ifdef OPTI
- texbind(TX_TEXTURE_0,i+1);
- #endif
- cpack(cpackValue);
- if (doLighting) n3f(xyNorm);
- bgnpolygon();
- #ifndef OPTI
- t0[1] = t1[1] = (float)i/(float)depth;
- t2[1] = t3[1] = (float)(i+1)/(float)depth;
- #endif
- t2f(t0);
- v3f(xy_v0);
- t2f(t1);
- v3f(xy_v1);
- t2f(t2);
- v3f(xy_v2);
- t2f(t3);
- v3f(xy_v3);
- endpolygon();
- }
- break;
- case _YZ :
- skipPolyCounter = 0;
- translate(x_sep*width/2.0,0,0);
- #ifndef OPTI
- if (lastSet != viewAxis) texbind(TX_TEXTURE_0,400);
- #endif
- for (i=0;i<width;i++) {
- /* if (degenMode && qtest()) break; */
- translate(-x_sep,0,0);
-
- /* weird logic to skip polygons */
- if (lightWeight) {
- if (skipPolyCounter < lightWeightCount) {
- skipPolyCounter++;
- continue;
- }
- else {
- skipPolyCounter = 0;
- }
- }
- #ifdef OPTI
- texbind(TX_TEXTURE_0,400+i+1);
- #endif
- cpack(cpackValue);
- if (doLighting) n3f(yzNorm);
- bgnpolygon();
- #ifndef OPTI
- t0[1] = t1[1] = (float)i/(float)width;
- t2[1] = t3[1] = (float)(i+1)/(float)width;
- #endif
- t2f(t0);
- v3f(yz_v0);
- t2f(t1);
- v3f(yz_v1);
- t2f(t2);
- v3f(yz_v2);
- t2f(t3);
- v3f(yz_v3);
- endpolygon();
- }
- break;
- case _ZX :
- skipPolyCounter = 0;
- translate(0,y_sep*height/2.0,0);
- #ifndef OPTI
- if (lastSet != viewAxis) texbind(TX_TEXTURE_0,800);
- #endif
- for (i=0;i<height;i++) {
- /* if (degenMode && qtest()) break; */
- translate(0,-y_sep,0);
-
- /* weird logic to skip polygons */
- if (lightWeight) {
- if (skipPolyCounter < lightWeightCount) {
- skipPolyCounter++;
- continue;
- }
- else {
- skipPolyCounter = 0;
- }
- }
- #ifdef OPTI
- texbind(TX_TEXTURE_0,800+i+1);
- #endif
- cpack(cpackValue);
- if (doLighting) n3f(zxNorm);
- bgnpolygon();
- #ifndef OPTI
- t0[1] = t1[1] = (float)i/(float)height;
- t2[1] = t3[1] = (float)(i+1)/(float)height;
- #endif
- t2f(t0);
- v3f(zx_v0);
- t2f(t1);
- v3f(zx_v1);
- t2f(t2);
- v3f(zx_v2);
- t2f(t3);
- v3f(zx_v3);
- endpolygon();
- }
- break;
- case _MXY :
- skipPolyCounter = 0;
- translate(0,0,-z_sep*depth/2.0);
- #ifndef OPTI
- if (lastSet != viewAxis) texbind(TX_TEXTURE_0,100);
- #endif
- for (i=depth-1;i>=0;i--) {
- /* if (degenMode && qtest()) break; */
- translate(0,0,z_sep);
-
- /* weird logic to skip polygons */
- if (lightWeight) {
- if (skipPolyCounter < lightWeightCount) {
- skipPolyCounter++;
- continue;
- }
- else {
- skipPolyCounter = 0;
- }
- }
- #ifdef OPTI
- texbind(TX_TEXTURE_0,i+1);
- #endif
- cpack(cpackValue);
- if (doLighting) n3f(mxyNorm);
- bgnpolygon();
- #ifndef OPTI
- t0[1] = t1[1] = (float)i/(float)depth;
- t2[1] = t3[1] = (float)(i+1)/(float)depth;
- #endif
- t2f(t0);
- v3f(xy_v0);
- t2f(t1);
- v3f(xy_v1);
- t2f(t2);
- v3f(xy_v2);
- t2f(t3);
- v3f(xy_v3);
- endpolygon();
- }
- break;
- case _MYZ :
- skipPolyCounter = 0;
- translate(-x_sep*width/2.0,0,0);
- #ifndef OPTI
- if (lastSet != viewAxis) texbind(TX_TEXTURE_0,400);
- #endif
- for (i=width-1;i>=0;i--) {
- /* if (degenMode && qtest()) break; */
- translate(x_sep,0,0);
-
- /* weird logic to skip polygons */
- if (lightWeight) {
- if (skipPolyCounter < lightWeightCount) {
- skipPolyCounter++;
- continue;
- }
- else {
- skipPolyCounter = 0;
- }
- }
- #ifdef OPTI
- texbind(TX_TEXTURE_0,400+i+1);
- #endif
- cpack(cpackValue);
- if (doLighting) n3f(myzNorm);
- bgnpolygon();
- #ifndef OPTI
- t0[1] = t1[1] = (float)i/(float)width;
- t2[1] = t3[1] = (float)(i+1)/(float)width;
- #endif
- t2f(t0);
- v3f(yz_v0);
- t2f(t1);
- v3f(yz_v1);
- t2f(t2);
- v3f(yz_v2);
- t2f(t3);
- v3f(yz_v3);
- endpolygon();
- }
- break;
- case _MZX :
- skipPolyCounter = 0;
- translate(0,-y_sep*height/2.0,0);
- #ifndef OPTI
- if (lastSet != viewAxis) texbind(TX_TEXTURE_0,800);
- #endif
- for (i=height-1;i>=0;i--) {
- /* if (degenMode && qtest()) break; */
- translate(0,y_sep,0);
- /* weird logic to skip polygons */
- if (lightWeight) {
- if (skipPolyCounter < lightWeightCount) {
- skipPolyCounter++;
- continue;
- }
- else {
- skipPolyCounter = 0;
- }
- }
- #ifdef OPTI
- texbind(TX_TEXTURE_0,800+i+1);
- #endif
- cpack(cpackValue);
- if (doLighting) n3f(mzxNorm);
- bgnpolygon();
- #ifndef OPTI
- t0[1] = t1[1] = (float)i/(float)height;
- t2[1] = t3[1] = (float)(i+1)/(float)height;
- #endif
- t2f(t0);
- v3f(zx_v0);
- t2f(t1);
- v3f(zx_v1);
- t2f(t2);
- v3f(zx_v2);
- t2f(t3);
- v3f(zx_v3);
- endpolygon();
- }
- break;
- }
- tevbind(TV_ENV0,0);
- }
-
- /* XXX3 */
-
- else if (textureMode == TEXTURE_3D) {
- tevbind(TV_ENV0,1);
- switch(viewAxis) {
- case _XY : /* 3D */
- skipPolyCounter = 0;
-
- tcoord[0][0] = 0.0; tcoord[0][1] = 0.0;
- tcoord[1][0] = 1.0; tcoord[1][1] = 0.0;
- tcoord[2][0] = 1.0; tcoord[2][1] = 1.0;
- tcoord[3][0] = 0.0; tcoord[3][1] = 1.0;
-
- translate(0,0,z_sep*depth/2.0);
-
- for (i=0;i<depth;i++) {
- /* if (degenMode && qtest()) break; */
-
- tcoord[0][2] = tcoord[1][2] =
- tcoord[2][2] = tcoord[3][2] = (float)i/(float)depth;
-
- translate(0,0,-z_sep);
-
- /* weird logic to skip polygons */
- if (lightWeight) {
- if (skipPolyCounter < lightWeightCount) {
- skipPolyCounter++;
- continue;
- }
- else {
- skipPolyCounter = 0;
- }
- }
- cpack(cpackValue);
- if (doLighting) n3f(xyNorm);
- bgnpolygon();
- t3f(tcoord[0]);
- v3f(xy_v0);
- t3f(tcoord[1]);
- v3f(xy_v1);
- t3f(tcoord[2]);
- v3f(xy_v2);
- t3f(tcoord[3]);
- v3f(xy_v3);
- endpolygon();
- }
- break;
-
- case _YZ : /* 3D */
- skipPolyCounter = 0;
-
- tcoord[0][1] = 0.0; tcoord[0][2] = 1.0;
- tcoord[1][1] = 1.0; tcoord[1][2] = 1.0;
- tcoord[2][1] = 1.0; tcoord[2][2] = 0.0;
- tcoord[3][1] = 0.0; tcoord[3][2] = 0.0;
-
- translate(x_sep*width/2.0,0,0);
- for (i=width-1;i>=0;i--) {
- /* if (degenMode && qtest()) break; */
-
- tcoord[0][0] = tcoord[1][0] =
- tcoord[2][0] = tcoord[3][0] = (float)i/(float)(width-1);
-
- translate(-x_sep,0,0);
-
- /* weird logic to skip polygons */
- if (lightWeight) {
- if (skipPolyCounter < lightWeightCount) {
- skipPolyCounter++;
- continue;
- }
- else {
- skipPolyCounter = 0;
- }
- }
-
- cpack(cpackValue);
- if (doLighting) n3f(yzNorm);
-
- bgnpolygon();
- t3f(tcoord[0]);
- v3f(yz_v0);
- t3f(tcoord[1]);
- v3f(yz_v1);
- t3f(tcoord[2]);
- v3f(yz_v2);
- t3f(tcoord[3]);
- v3f(yz_v3);
- endpolygon();
- }
- break;
- case _ZX : /* 3D */
- skipPolyCounter = 0;
-
- tcoord[0][2] = 0.0; tcoord[0][0] = 0.0;
- tcoord[1][2] = 1.0; tcoord[1][0] = 0.0;
- tcoord[2][2] = 1.0; tcoord[2][0] = 1.0;
- tcoord[3][2] = 0.0; tcoord[3][0] = 1.0;
-
- translate(0,y_sep*height/2.0,0);
- for (i=height-1;i>=0;i--) {
- /* if (degenMode && qtest()) break; */
-
- tcoord[0][1] = tcoord[1][1] =
- tcoord[2][1] = tcoord[3][1] = (float)i/(float)(height-1);
-
- translate(0,-y_sep,0);
-
- /* weird logic to skip polygons */
- if (lightWeight) {
- if (skipPolyCounter < lightWeightCount) {
- skipPolyCounter++;
- continue;
- }
- else {
- skipPolyCounter = 0;
- }
- }
- cpack(cpackValue);
- if (doLighting) n3f(zxNorm);
- bgnpolygon();
- t3f(tcoord[0]);
- v3f(zx_v0);
- t3f(tcoord[1]);
- v3f(zx_v1);
- t3f(tcoord[2]);
- v3f(zx_v2);
- t3f(tcoord[3]);
- v3f(zx_v3);
- endpolygon();
- }
-
- break;
- case _MXY : /* 3D */
- skipPolyCounter = 0;
-
- tcoord[0][0] = 0.0; tcoord[0][1] = 0.0;
- tcoord[1][0] = 1.0; tcoord[1][1] = 0.0;
- tcoord[2][0] = 1.0; tcoord[2][1] = 1.0;
- tcoord[3][0] = 0.0; tcoord[3][1] = 1.0;
-
- translate(0,0,-z_sep*depth/2.0);
- for (i=depth-1;i>=0;i--) {
- /* if (degenMode && qtest()) break; */
-
- tcoord[0][2] = tcoord[1][2] =
- tcoord[2][2] = tcoord[3][2] = (float)i/(float)(depth-1);
-
- translate(0,0,z_sep);
- /* weird logic to skip polygons */
- if (lightWeight) {
- if (skipPolyCounter < lightWeightCount) {
- skipPolyCounter++;
- continue;
- }
- else {
- skipPolyCounter = 0;
- }
- }
- cpack(cpackValue);
- if (doLighting) n3f(mxyNorm);
- bgnpolygon();
- t3f(tcoord[0]);
- v3f(xy_v0);
- t3f(tcoord[1]);
- v3f(xy_v1);
- t3f(tcoord[2]);
- v3f(xy_v2);
- t3f(tcoord[3]);
- v3f(xy_v3);
- endpolygon();
- }
- break;
-
- case _MYZ : /* 3D */
- skipPolyCounter = 0;
-
- tcoord[0][1] = 0.0; tcoord[0][2] = 1.0;
- tcoord[1][1] = 1.0; tcoord[1][2] = 1.0;
- tcoord[2][1] = 1.0; tcoord[2][2] = 0.0;
- tcoord[3][1] = 0.0; tcoord[3][2] = 0.0;
-
- translate(-x_sep*width/2.0,0,0);
- for (i=0;i<width;i++) {
- /* if (degenMode && qtest()) break; */
-
- tcoord[0][0] = tcoord[1][0] =
- tcoord[2][0] = tcoord[3][0] = (float)i/(float)(width);
- translate(x_sep,0,0);
-
- /* weird logic to skip polygons */
- if (lightWeight) {
- if (skipPolyCounter < lightWeightCount) {
- skipPolyCounter++;
- continue;
- }
- else {
- skipPolyCounter = 0;
- }
- }
- cpack(cpackValue);
- if (doLighting) n3f(myzNorm);
- bgnpolygon();
- t3f(tcoord[0]);
- v3f(yz_v3);
- t3f(tcoord[1]);
- v3f(yz_v2);
- t3f(tcoord[2]);
- v3f(yz_v1);
- t3f(tcoord[3]);
- v3f(yz_v0);
- endpolygon();
- }
-
- break;
- case _MZX : /* 3D */
- skipPolyCounter = 0;
-
- tcoord[0][2] = 0.0; tcoord[0][0] = 1.0;
- tcoord[1][2] = 1.0; tcoord[1][0] = 1.0;
- tcoord[2][2] = 1.0; tcoord[2][0] = 0.0;
- tcoord[3][2] = 0.0; tcoord[3][0] = 0.0;
-
- translate(0,-y_sep*height/2.0,0);
- for (i=0;i<height;i++) {
- if (degenMode && qtest()) {
- break;
- }
- tcoord[0][1] = tcoord[1][1] =
- tcoord[2][1] = tcoord[3][1] = (float)i/(float)(height);
- translate(0,y_sep,0);
-
- /* weird logic to skip polygons */
- if (lightWeight) {
- if (skipPolyCounter < lightWeightCount) {
- skipPolyCounter++;
- continue;
- }
- else {
- skipPolyCounter = 0;
- }
- }
-
- cpack(cpackValue);
- if (doLighting) n3f(mzxNorm);
- bgnpolygon();
- t3f(tcoord[0]);
- v3f(zx_v3);
- t3f(tcoord[1]);
- v3f(zx_v2);
- t3f(tcoord[2]);
- v3f(zx_v1);
- t3f(tcoord[3]);
- v3f(zx_v0);
- endpolygon();
- }
-
- break;
- } /* sw viewAxis in 3d */
- /*
- texbind(TX_TEXTURE_0,0);
- */
- tevbind(TV_ENV0,0);
- } /* 3D texture */
-
- if (!dontBlend)
- blendfunction( BF_ONE, BF_ZERO );
-
- popmatrix();
- if (drawAxis) drawAxes();
-
- if (doClipping && displayClipPlanes) {
- for (i=0;i<6;i++) {
- if (clip[i].onOff==1) {
- drawClippingPlane(i);
- }
- }
- }
-
- break; /* case TEXTURE */
- } /* switch drawmode */
-
- lastSet = viewAxis;
-
- if (doubleBuffer) swapbuffers();
-
- if (doLighting) {
- lmbind(LMODEL,0);
- }
- if (fog) {
- fogvertex(FG_OFF,0);
- }
- if (doClipping) {
- for (i=0;i<6;i++) {
- if (clip[i].onOff == 1) {
- clipplane(i,CP_OFF,0);
- }
- }
- }
- }
-
- void
- drawAxes()
- {
- RGBcolor(0,255,0);
- move(0.0,0.0,0.0);
- draw(bmaxx,0.0,0.0);
- cmov(0.95*bmaxx,0.0,0.0);
- if (isFacing(1.0,0.0,0.0))
- charstr("x");
-
- RGBcolor(0,0,255);
- move(0.0,0.0,0.0);
- draw(0.0,bmaxy,0.0);
- cmov(0.0,0.95*bmaxy,0.0);
- if (isFacing(0.0,1.0,0.0))
- charstr("y");
-
- RGBcolor(255,0,0);
- move(0.0,0.0,0.0);
- draw(0.0,0.0,bmaxz);
- cmov(0.0,0.0,0.95*bmaxz);
- if (isFacing(0.0,0.0,1.0))
- charstr("z");
- }
-
- int
- isFacing(nx,ny,nz)
- float nx,ny,nz;
- {
- float viewDir[3],planeDir[3];
- Matrix foo,vinv;
-
- getmatrix(foo);
- invert4d( foo, vinv );
-
- viewDir[0] = -vinv[2][0];
- viewDir[1] = -vinv[2][1];
- viewDir[2] = -vinv[2][2];
-
- normalize(&viewDir[0],&viewDir[1],&viewDir[2]);
-
- planeDir[0] = nx;
- planeDir[1] = ny;
- planeDir[2] = nz;
-
- normalize(&planeDir[0],&planeDir[1],&planeDir[2]);
-
- if ((viewDir[0]*planeDir[0])+
- (viewDir[1]*planeDir[1])+
- (viewDir[2]*planeDir[2]) <= 0) return(1);
- else
- return(0);
- }
-
- int
- optimumSet()
- {
- float viewDir[3];
- Matrix foo,vinv;
- float maxf,xy,yz,zx;
- int im;
-
- getmatrix(foo);
- invert4d( foo, vinv );
-
- viewDir[0] = -vinv[2][0];
- viewDir[1] = -vinv[2][1];
- viewDir[2] = -vinv[2][2];
-
- normalize(&viewDir[0],&viewDir[1],&viewDir[2]);
-
- xy = viewDir[2]; /* simplified because 0*xx + 0*yy + 1*zz */
- yz = viewDir[0];
- zx = viewDir[1];
-
- maxf = ABS(xy);
- im = (xy < 0.0) ? _XY : _MXY;
-
- if (maxf <= ABS(yz)) {
- maxf = ABS(yz);
- im = (yz < 0.0) ? _YZ : _MYZ;
- }
-
- if (maxf <= ABS(zx)) {
- maxf = ABS(zx);
- im = (zx < 0.0) ? _ZX : _MZX;
- }
-
- if (lockAView != 0) {
- im = (im < 0) ? -lockAView : lockAView;
- }
-
- return(im);
- }
-
- void
- drawClippingPlane(n)
- int n;
- {
- static float square[4][3];
- static float norm[3];
-
- switch(n) {
- case 0 :
- RGBcolor(255,0,0);
- square[0][_X] = clip[n].xyz[_X];
- square[0][_Y] = bminy;
- square[0][_Z] = bminz;
-
- square[1][_X] = clip[n].xyz[_X];
- square[1][_Y] = bminy;
- square[1][_Z] = bmaxz;
-
- square[2][_X] = clip[n].xyz[_X];
- square[2][_Y] = bmaxy;
- square[2][_Z] = bmaxz;
-
- square[3][_X] = clip[n].xyz[_X];
- square[3][_Y] = bmaxy;
- square[3][_Z] = bminz;
- norm[0] = -1.0;
- norm[1] = 0.0;
- norm[2] = 0.0;
-
- break;
- case 1 :
- RGBcolor(0,255,0);
- square[0][_X] = clip[n].xyz[_X];
- square[0][_Y] = bminy;
- square[0][_Z] = bminz;
-
- square[1][_X] = clip[n].xyz[_X];
- square[1][_Y] = bmaxy;
- square[1][_Z] = bminz;
-
- square[2][_X] = clip[n].xyz[_X];
- square[2][_Y] = bmaxy;
- square[2][_Z] = bmaxz;
-
- square[3][_X] = clip[n].xyz[_X];
- square[3][_Y] = bminy;
- square[3][_Z] = bmaxz;
- norm[0] = 1.0;
- norm[1] = 0.0;
- norm[2] = 0.0;
-
- break;
- case 2 :
- RGBcolor(255,255,0);
- square[0][_X] = bminx;
- square[0][_Y] = clip[n].xyz[_Y];
- square[0][_Z] = bminz;
-
- square[1][_X] = bminx;
- square[1][_Y] = clip[n].xyz[_Y];
- square[1][_Z] = bmaxz;
-
- square[2][_X] = bmaxx;
- square[2][_Y] = clip[n].xyz[_Y];
- square[2][_Z] = bmaxz;
-
- square[3][_X] = bmaxx;
- square[3][_Y] = clip[n].xyz[_Y];
- square[3][_Z] = bminz;
- norm[0] = 0.0;
- norm[1] = -1.0;
- norm[2] = 0.0;
-
- break;
- case 3 :
- RGBcolor(0,0,255);
- square[0][_X] = bminx;
- square[0][_Y] = clip[n].xyz[_Y];
- square[0][_Z] = bminz;
-
- square[1][_X] = bmaxx;
- square[1][_Y] = clip[n].xyz[_Y];
- square[1][_Z] = bminz;
-
- square[2][_X] = bmaxx;
- square[2][_Y] = clip[n].xyz[_Y];
- square[2][_Z] = bmaxz;
-
- square[3][_X] = bminx;
- square[3][_Y] = clip[n].xyz[_Y];
- square[3][_Z] = bmaxz;
- norm[0] = 0.0;
- norm[1] = 1.0;
- norm[2] = 0.0;
-
- break;
- case 4 :
- RGBcolor(255,0,255);
- square[0][_X] = bminx;
- square[0][_Y] = bminy;
- square[0][_Z] = clip[n].xyz[_Z];
-
- square[1][_X] = bminx;
- square[1][_Y] = bmaxy;
- square[1][_Z] = clip[n].xyz[_Z];
-
- square[2][_X] = bmaxx;
- square[2][_Y] = bmaxy;
- square[2][_Z] = clip[n].xyz[_Z];
-
- square[3][_X] = bmaxx;
- square[3][_Y] = bminy;
- square[3][_Z] = clip[n].xyz[_Z];
- norm[0] = 0.0;
- norm[1] = 0.0;
- norm[2] = -1.0;
-
- break;
- case 5 :
- RGBcolor(0,255,255);
- square[0][_X] = bminx;
- square[0][_Y] = bminy;
- square[0][_Z] = clip[n].xyz[_Z];
-
- square[1][_X] = bmaxx;
- square[1][_Y] = bminy;
- square[1][_Z] = clip[n].xyz[_Z];
-
- square[2][_X] = bmaxx;
- square[2][_Y] = bmaxy;
- square[2][_Z] = clip[n].xyz[_Z];
-
- square[3][_X] = bminx;
- square[3][_Y] = bmaxy;
- square[3][_Z] = clip[n].xyz[_Z];
- norm[0] = 0.0;
- norm[1] = 0.0;
- norm[2] = 1.0;
-
- break;
- }
-
- bgnclosedline();
- v3f(square[0]);
- v3f(square[1]);
- v3f(square[2]);
- v3f(square[3]);
- endclosedline();
- }
-
- unsigned long
- packc(a,b,g,r)
- {
- unsigned long retval;
- retval = 0;
- retval = (a<<24 | b<<16 | g<<8 | r);
- return(retval);
- }
-